import EchartComponent from "./echaets";
import { useEffect, useState } from "react";

const initData = {
  title: {
    text: "男女占比比例",
    left:"center",
  },
  tooltip: {
    trigger: 'item'
  },
  legend:{
    orient: 'vertical',
    left:"left",
  },
  series: [
    {
      name: "男女",
      type: "pie",
      radius: '50%',
      data: [
        { value: 1, name: 'man' },
        { value: 1, name: 'woman' },
      ],
    },
  ],
};
function Home() {
  const [option, setOption] = useState(initData);
  function getData() {
    // 第一个图形
    option.series[0].data = [
        { value: 108, name: 'man' },
        { value: 75, name: 'woman' },
      ];
    setOption(JSON.parse(JSON.stringify(option)));
  }
  useEffect(() => {
    getData()}, []);

  return (
    <>
      <EchartComponent title="饼状图" options={option}></EchartComponent>
    </>
  );
}
export default Home;
